﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace Fireball.OpenXML
{
    public abstract class ObservableEntityCollection<T> : ObservableCollection<T> where T : OpenXMLEntity
    {
        private OpenXMLEntity _Owner = null;

        public ObservableEntityCollection(OpenXMLEntity owner)
        {
            _Owner = owner;
        }

        protected override void InsertItem(int index, T item)
        {
            if (this._Owner != null)
                ((OpenXMLEntity)item).SetOwner(this._Owner);

            base.InsertItem(index, item);
        }
    }
}
